const app = getApp();
Page({
  data: {
    pifu_list:[],
    index_bg:'',
  },

  onShow:function(){

  },

  onLoad:function(e){
    this.getUserInfo();
  },

  //获取个人信息
  getUserInfo:function(){
    let _this = this;
    app._post('api/member/getUserInfo', {}, function(result) {
      if(result.code == 200){
        _this.setData({
          index_bg:result.data.index_bg
        })
        _this.get_pifu_list();
      }else{
        wx.navigateTo({
          url: '/pages/auth/auth'
        })
      }
    });
  },

  //获取个人信息
  get_pifu_list:function(){
    let _this = this,
     index_bg = _this.data.index_bg;
    app._post('api/member/get_pifu_list', {}, function(result) {
      var pifu_data = result.data;
      for(var i=0;i<pifu_data.length;i++){
        if(pifu_data[i].banner_id == index_bg){
          pifu_data[i].tips = '已选中';
          pifu_data[i].disabled = true;
        }else{
          pifu_data[i].tips = '预览';
          pifu_data[i].disabled = false;
        }
      }
      _this.setData({
        pifu_list:result.data
      })
    });
  },

  //预览：
  set_pifa:function(e){
    let _this = this,
     banner_id = e.currentTarget.dataset.bannerid;
    wx.navigateTo({
      url: './pifu_yulan?banner_id='+banner_id
    })
  },

})